import { useApi } from '../../useApi'
import type { TestData, ApiResponse } from '~/types/api'

/**
 * 测试相关API
 */
export const useTestApi = () => {
    const { get, post } = useApi()

    /**
     * 获取测试数据
     * @returns Promise<TestData>
     */
    const getTestData = async (): Promise<TestData> => {
        return get<TestData>('/api/test')
    }

    /**
     * 提交测试数据
     * @param data 测试数据
     * @returns Promise<ApiResponse<{ success: boolean }>>
     */
    const submitTestData = async (data: any): Promise<ApiResponse<{ success: boolean }>> => {
        return post<ApiResponse<{ success: boolean }>>('/api/test', data)
    }

    return {
        getTestData,
        submitTestData
    }
}